﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using DrugStore.Models;
using DrugStore.Helper;

namespace DrugStore.Controllers
{
    public class NewsController : Controller
    {
        private NewBussiness objBussiness;
        //
        // GET: /New/

        public ActionResult Index(int index=1)
        {
            const int pageSize = 5;
            try 
            {
               
                objBussiness = new NewBussiness();
                PaginateList<News> news = objBussiness.GetAllNews(index,pageSize);
                return View(news);
            }
            catch (System.Exception ex) 
            {
                ViewData["error"] = ex.Message;
            }
            return null;
        }

        //
        // GET: /New/Details/5

        public ActionResult Details(String id)
        {
            objBussiness = new NewBussiness();
            NewModels news = objBussiness.GetNewById(id);
            return View(news);
        }
    }
}
